var dataSource = new Array();
//table的数据源
var table;   //table对象
dataSource = [];
web.user_list=(function(){
    return function(page,current,obj,scrollLoad){
        var user_data = {
            customerId:"1",
        }
        var succCallBack = function (data, status, response) {
            console.log(data)
            $.each(data.userList, function (i, field) {
                console.log(field.DEPARTMENT_NAME)
                var rowData = new Array();
                rowData.push(field.NUMBER);
                rowData.push(field.ROLE_NAME);
                rowData.push(field.DEPARTMENT_NAME);
                rowData.push(field.PHONE);
                rowData.push(field.EMAIL);
                rowData.push(field.ENTRY_TIME);
                rowData.push(field.STATUS);
                rowData.push(field.NAME);
                rowData.push(field.USERNAME);
                rowData.push(field.BIANMA);
                dataSource.push(rowData);
            })
            initDataTable(dataSource);
            function initDataTable(dataSource) {
                var dttable = $('#datatable').dataTable( ); // 初始化dataTable，清空上一个值
                dttable.fnClearTable(); //清空一下table
                dttable.fnDestroy(); //还原初始化了的datatable
                $("#datatable").DataTable({
                    "autoWidth": false,
                    "ordering": true,
                    "searching": true,
                    "paging": true,
                    "retrieve": true,
                    "destroy": true,
                    "bAutoWidth": true,
                    "bLengthChange": true,
                    "aLengthMenu":[5,10,25,50],
                    "oLanguage": {
                        "sLengthMenu": "每页显示 _MENU_ 条记录",
                        "sZeroRecords": "抱歉， 没有找到",
                        "sInfo": "从 _START_ 到 _END_ /共 _TOTAL_ 条数据",
                        "sInfoEmpty": "没有数据",
                        "sInfoFiltered": "(从 _MAX_ 条数据中检索)",
                        "oPaginate": {
                            "sFirst": "首页",
                            "sPrevious": "前一页",
                            "sNext": "后一页",
                            "sLast": "尾页"
                        },
                        "sZeroRecords": "没有检索到数据",
                        "sProcessing": "<img src='./loading.gif' />"
                    },
                    data: dataSource,
                    columnDefs: [
                        {
                            "visible": true,
                            "targets": 0
                        },
                        {
                            "render": function(data,type,row,meta){
                                var val = '<span>工号：'+row[0]+'</span><br><span>姓名：'+row[7]+'</span><br><span>用户名：'+row[8]+'</span>';
                                return val;
                            },
                            "targets": 0
                        },
                        {
                            "render": function(data,type,row,meta){
                                var val = '<a><span class="list" onclick="ood_edit(\'修改信息\',\'account-add.html\',\''+row+'\')"><i class="Hui-iconfont ml-10">&#xe60c;</i></span class="list" onclick="user_stop()"><i class="Hui-iconfont ml-10">&#xe60e;</a>';
                                console.log(row)
                                return val;
                            },
                            "targets": 7
                        }

                    ]
                });
            };
        };
        // "http://192.168.0.53:8680/rights/user/listUsersApi"
        return web.doAjax(root.accessInter.access_user_listUsersApi,'post',user_data, succCallBack);
    }
})();